//
//  MainViewController.swift
//  微博
//
//  Created by mac on 15/12/12.
//  Copyright © 2015年 itcats. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    //必选属性
    let mainTabBar = MainTabBar()
    
    @objc  private func composeBtnClick(){
    print(__FUNCTION__)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
   // print(tabBar.classForCoder)
       mainTabBar.composeBtn.addTarget(self, action: "composeBtnClick", forControlEvents: .TouchUpInside)
        
        setValue(mainTabBar, forKey: "TabBar")
        print(tabBar.classForCoder)
      addChildViewControllers()
    }

    
    
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    
    
    
    private func addChildViewController(vc: UIViewController,title: String,imageName: String) {
        let nav = UINavigationController(rootViewController: vc)
        vc.title = title
        //设置图片
        vc.tabBarItem.image = UIImage(named: imageName)
        addChildViewController(nav)
        
    }
    
    
    

}
